﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;
using DevExpress.MailClient.Win.Forms.Cible;
using DevExpress.XtraEditors;
using Zero.DataLayer;
using Zero.DataLayer.Repository;
using Zero.POCO;
using Zero.Presenter;

namespace DevExpress.MailClient.Win.Modules
{
    public partial class Cible  :  BaseModule,ICibleView
    {
        public List<int> ListeEquipement { get; set; }
        public List<int> listeCSE { get; set; }
        public List<int> listeCSP { get; set; }
        public List<int> listeNbChambre { get; set; }
        public List<int> listeHabitat { get; set; }
        public List<int> listeNbVoiture { get; set; }
        public List<int> listeNivInstruc { get; set; }
        public List<int> listeRevenue { get; set; }
        public List<int> listeMatromonia { get; set; }
        public List<int> listeStatutFamil { get; set; }
        public List<int> listeTypeHabitat { get; set; }
        public List<int> listeGenre { get; set; }
        public List<Filter> Filtres { get; set; }
        public CiblePresenter CiblePresenter;
        public Cible()
        {
            InitializeComponent();

            CiblePresenter=new CiblePresenter(this,new FilterRepository());
            CiblePresenter.Display();

            GCCible.DataSource = Filtres;
        }

        

        protected internal override void ButtonClick(string tag)
        {
            switch (tag)
            {
                case TagResources.NewCible:
                    CreateNewCible();
                    break;
            }
        }

        private void CreateNewCible()
        {
            var cibleForm = new GestionCible(null,true);
            var resultat=cibleForm.ShowDialog();
            if (resultat != DialogResult.OK) return;
            ListeEquipement = cibleForm.listeEquipement;
            listeCSP = cibleForm.listeCSP;
            listeCSE = cibleForm.listeCSE;
            listeNbChambre = cibleForm.listeNbChambre;
            listeHabitat = cibleForm.listeHabitat;
            listeMatromonia = cibleForm.listeMatromonia;
            listeNbVoiture = cibleForm.listeNbVoiture;
            listeNivInstruc = cibleForm.listeNivInstruc;
            listeRevenue = cibleForm.listeRevenue;
            listeStatutFamil = cibleForm.listeStatutFamil;
            listeTypeHabitat = cibleForm.listeTypeHabitat;
            listeGenre = cibleForm.listeGenre;
            CiblePresenter.WriteChanges(cibleForm.filtre);

            CiblePresenter.Display();
            GCCible.DataSource = Filtres;
            GCCible.RefreshDataSource();
        }
    }
}
